package com.myres.servlet;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;


public class Server {
	
	public static void main(String[] agrs){
	try{
		final ServerSocket 
		ss=new ServerSocket(8989);
		
		System.out.println("server socket is started!!!....................................");
		new Thread(){
			public void run(){
				try{
					while(true){
						System.out.println("accepting................................................");
				        Socket s=ss.accept();
				        System.out.println("a client is hooked................................................");
				        InputStream is=s.getInputStream();
				        byte[] buf=new byte[128];
				        int len;
				        StringBuffer sb=new StringBuffer();
				      //  while((len=is.read(buf, 0, 128))!=-1){
				    	//    System.out.println("reading................................................"+len);
					    //    sb.append(new String(buf,0,len));
				        // }
				        is.close();
				        String id=sb.toString();
				        System.out.println("message="+id);
					}
				}catch(IOException e){
					e.printStackTrace();
				}
				
			}
		}.start();
		}catch(IOException e){
			e.printStackTrace();
		}
	}
}
